package steven.sdc.appPoker.Fragment;

import com.amurani.slidingmenu.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Spinner;
import android.widget.TextView;

public class FragmentThangTrang extends Fragment {
	FragmentNguoiDenBai	dt =new FragmentNguoiDenBai();
	Button xacnhan;
	RadioGroup raido_group;
	Spinner spin_nguoithang;
	String [] arr ={"Bình","Hoàng","Nam","Tiến"};
	ArrayAdapter<String> adapter;
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreateView(inflater, container, savedInstanceState);
		View view=inflater.inflate(R.layout.thang_trang, null);
		Init(view);
		return view;
	}
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		SpinerSetData();
		
	}
	public void Init(View view)
	{
		xacnhan=(Button)view.findViewById(R.id.button_xacnhan);
		raido_group=(RadioGroup)view.findViewById(R.id.radio_group);
		spin_nguoithang=(Spinner)view.findViewById(R.id.spinner1_nguoithangtrang);
		
		
	}
	public void SpinerSetData()
	{
		adapter=new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,arr);
		 adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
		spin_nguoithang.setAdapter(adapter);
		raido_group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				switch (checkedId) {
				case R.id.radio_co:
				{
			
				getFragmentManager().beginTransaction().add(R.id.fragment_nguoidenbai, dt,null).commitAllowingStateLoss();
				}
				break;
				case R.id.radio_khong:
				{
					
					getFragmentManager().beginTransaction().remove(dt).commitAllowingStateLoss();
				}
					
					break;

				}
				
			}
		});
//		 xacnhan.setOnClickListener(new OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				FragmentNguoiDenBai dt=new FragmentNguoiDenBai();
//				getFragmentManager().beginTransaction().add(R.id.fragment_nguoidenbai, dt,null).commitAllowingStateLoss();
//			}
//		});
	}

}
